import React, { Component } from "react";
// 引入PropTypes,用于做props的类型检查
import { number, string } from "prop-types";

class Child1 extends Component {
  static propTypes = {
    msg: string,
    count: number,
  };

  render() {
    const { msg, count } = this.props;
    return (
      <div>
        child1 - {msg} - {count}
      </div>
    );
  }
}
// Child1.propTypes = {
//   // key是props的值，value是类型
//   msg: PropTypes.number,
// };

const Child2 = ({ msg }) => {
  return <div>child2 - {msg}</div>;
};

class App extends Component {
  render() {
    return (
      <>
        <h3>props类型</h3>
        <Child1 msg="hello" count={10} />
        <Child2 msg="hello2" />
      </>
    );
  }
}

export default App;
